<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>设备借还管理</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=201908121454" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/common.js?v=201907231346" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>

    <style>
        .layui-card-header {
            border-bottom: 1px solid #eee;
        }
        .cellBack{
            background-color:#f2f2f2;
        }
        .white{
            display: inline-block;
            width: 38px;
        }

        .mbox {
            padding: 8px;
        }
        .inbox {
            padding: 5px;
            padding-right: 30px;
        }
        .layui-btn {
            margin-left: 10px;
        }
        .layui-btn .layui-icon {
            margin-right: 0px;
        }
        .red {
            color: red;
            font-size: 16px;
        }
        .layui-form-label {
            padding: 8px 15px;
        }
        .layui-card-body {
            display: flex;
            padding: 0px;
        }
        .layui-lf {
            min-width: 10%;
            overflow-x: auto;
        }
        .layui-rt {
            width: 100%;
        }
        .layui-form-select .layui-input{
            height: 32px;
        }
        .layui-tab-title{
            height: 32px;
        }

        .layui-tab-title li{
            height: 33px;
            line-height: 33px;
        }
        .layui-tab layui-tab-card{
            margin-top: -4px;
        }
        .layui-tab-card>.layui-tab-title .layui-this:after {
            border-width: 0px;
        }
        .layui-table{
            margin-top: -2px !important;
        }
        .layui-table-view .layui-table td, .layui-table-view .layui-table th{
            padding: 2px 0;
        }
        #infoId td{
            padding: 5px 2px;
        }
        .tablecolor{
            background-color:#f2f2f2;
        }
        .layui-table{
            width:100%!important;
        }
    </style>
</head>
<body>
<div class="mbox">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-rt">
                <div class="layui-tab layui-tab-card" lay-filter="tabtoggle">
                    <ul class="layui-tab-title">
                        <li class="layui-this">待批申请</li>
                        <li>已准申请</li>
                        <li>未准申请</li>
                        <li>设备归还</li>
                    </ul>
                    <%--页签下面内容--%>
                    <div class="layui-tab-content" style="height:100%;padding: 0 10px 10px 10px">
                        <div class="layui-tab-item layui-show">
                            <table class="layui-table" lay-skin="line" id="Settlement" lay-size="sm" lay-filter="SettlementFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">借还设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="deviceDetail" lay-filter="deviceDetail" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <table class="layui-table" lay-skin="line" id="approvalTable" lay-size="sm" lay-filter="approvalTableFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">借还设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="approvalDetail" lay-filter="approvalFilter" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <table class="layui-table" lay-skin="line" id="notexactlyTable" lay-size="sm" lay-filter="notexactlyTableFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">借还设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="notexactlyDetail" lay-filter="notexactlyFilter" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <table class="layui-table" lay-skin="line" id="devicebl" lay-size="sm" lay-filter="deviceblFilter"></table>
                            <div class="layui-tab layui-tab-card" lay-filter="bottomTab" style="position: relative;z-index: 0;">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">借还设备明细</li>
                                </ul>
                                <div class="layui-tab-content" style="padding: 0 10px">
                                    <div class="layui-tab-item layui-show">
                                        <table id="deviceblDetail" lay-filter="borrowDlFilter" lay-size="sm"> </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%--报废申请新增/删除撤销/查询字段--%>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm"  lay-event="approval" style="width: 70px">批准</button>
        <button class="layui-btn layui-btn-sm" lay-event="disApproval" style="width: 100px">不批准</button>
    </div>
    <div class="demoTable" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"lay-search="" placeholder="请选择" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="BORROWER_USER">借用人</option>
                <option value="BORROWER_DETP_ID">借用部门</option>
                <option value="BORROW_TIME">借用日期</option>
                <option value="EXPECT_RETURN_DATE">预计归还日期</option>
                <option value="BORROWER_OPERATION_USER">借出人</option>
                <option value="LEND_DEPT_ID">借出部门</option>
                <option value="WORKFLOW_NO">流水号</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" name="searchtext"  autocomplete="off" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload"   lay-event="searchCust" style="height:30px;line-height: 30px; ">搜索</button>
        </div>
    </div>
</script>
<%--查询字段（已准）--%>
<script type="text/html" id="accurate">
    <div class="demoTablea" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"  placeholder="请选择" lay-search="" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="RETURN_STATUS">处理状态</option>
                <option value="BORROWER_USER">借用人</option>
                <option value="BORROWER_DETP_ID">借用部门</option>
                <option value="BORROW_TIME">借用日期</option>
                <option value="EXPECT_RETURN_DATE">预计归还日期</option>
                <option value="BORROWER_OPERATION_USER">借出人</option>
                <option value="LEND_DEPT_ID">借出部门</option>
                <option value="BORROW_OPERATION_TIME">借出日期</option>
                <option value="APPROVER">审批人</option>
                <option value="APPROVER_TIME">审批日期</option>
                <option value="WORKFLOW_NO">流水号</option>
                <option value="MEMO">备注</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" name="searchtexta" autocomplete="off" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload"  lay-event="searchCusta" style="height:30px;line-height: 30px;">搜索</button>
        </div>
    </div>
</script>
<%--查询字段（未批）--%>
<script type="text/html" id="notexactly">
    <div class="demoTableb" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"  placeholder="请选择" lay-search="" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="BORROWER_USER">借用人</option>
                <option value="BORROWER_DETP_ID">借用部门</option>
                <option value="BORROW_TIME">借用日期</option>
                <option value="EXPECT_RETURN_DATE">预计归还日期</option>
                <option value="BORROWER_OPERATION_USER">借出人</option>
                <option value="LEND_DEPT_ID">借出部门</option>
                <option value="WORKFLOW_NO">流水号</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" name="searchtextb" autocomplete="off" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload"  lay-event="searchCustb" style="height:30px;line-height: 30px;">搜索</button>
        </div>
    </div>
</script>
<%--设备归还/查询字段--%>
<script type="text/html" id="accept">
    <div class="demoTablec" style="position:absolute;right: 8%;top: 10px;width: 600px;height: 30px">
        <label style="float: left;width: 60px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="modules" lay-verify="required" lay-filter="serachInfo"  placeholder="请选择" lay-search="" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="RETURN_STATUS">处理状态</option>
                <option value="BORROWER_USER">借用人</option>
                <option value="BORROWER_DETP_ID">借用部门</option>
                <option value="BORROW_TIME">借用日期</option>
                <option value="EXPECT_RETURN_DATE">预计归还日期</option>
                <option value="BORROWER_OPERATION_USER">借出人</option>
                <option value="LEND_DEPT_ID">借出部门</option>
                <option value="BORROW_OPERATION_TIME">借出日期</option>
                <option value="APPROVER">审批人</option>
                <option value="APPROVER_TIME">审批日期</option>
                <option value="WORKFLOW_NO">流水号</option>
                <option value="MEMO">备注</option>
            </select>
        </div>
        <div style="float: left">
            <div class="layui-inline">
                <input class="layui-input" autocomplete="off"  name="searchtextc" style="height: 32px;margin-left: 6px;">
            </div>
            <button class="layui-btn" data-type="reload" lay-event="searchCustc" style="height:30px;line-height: 30px; ">搜索</button>
        </div>
    </div>
</script>
<%--借还申请上头部--%>
<script type="text/html" id="barOperation">
    <a class="layui-btn layui-btn-xs" lay-event="approval">批准</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="disApproval">不批准</a>
</script>
<%--设备归还操作--%>
<script type="text/html" id="barOperation3">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="returnlend">归还</a>
</script>
<script type="text/javascript">
    var settlementTable,
        approvalTable,
        notexactlyTable,
        devicebl,
        deviceDetail;
    var lendId;
    var topindexPage=0;
    var col = [[
        {field: 'equipNo', title: '固定资产编号'}
        , {field: 'equipName', title: '设备名称'}
        , {field: 'factoryNo', title: '出厂编号'}
        , {field: 'equipTypeName', title: '设备类型'}
        , {field: 'equipStatuasCode', title: '资产状态'}
        , {field: 'modelNo', title: '型号'}
        , {field: 'spec', title: '规格'}
    ]];
    var mcol = [[
         {field: 'equipNo', title: '固定资产编号'}
        , {field: 'equipName', title: '设备名称'}
        , {field: 'factoryNo', title: '出厂编号'}
        , {field: 'equipTypeName', title: '设备类型'}
        , {field: 'equipStatuasCode', title: '资产状态'}
        , {field: 'modelNo', title: '型号'}
        , {field: 'spec', title: '规格'}
        , {field: 'returnUser', title: '归还人'}
        , {field: 'returnTime', title: '归还时间'}
        , {field: 'returnStatus', title: '归还状态',templet:function(d){
                if (d.returnStatus == 0) {
                    return "未归还"
                } else if (d.returnStatus == 1) {
                    return "已归还"
                }
            }}
        // , {width: 100, title: '操作', align: 'center', toolbar: '#barOperation3'}
    ]];
    layui.use(['table', 'layer','laydate', 'form', 'element'], function () {
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var element = layui.element;
        var laydate = layui.laydate;

        //借还申请表格实例
        settlementTable = table.render({
            elem: '#Settlement'
            , page: true //开启分页
            , url: '/EquipBorrow/getAdministration?ApprovalStatus=1'//数据接口
            , toolbar: '#toolbar'
            , cols: [[{type: 'checkbox', field: 'lendId'}
                , {
                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                        if (d.approverStatus == 0) {
                            return "新建"
                        } else if (d.approverStatus == 1) {
                            return "待批准"
                        } else if (d.approverStatus == 2) {
                            return "已批准"
                        } else if (d.approverStatus == 3) {
                            return "未批准"
                        }
                    }
                }
                , {field: 'borrowerUser', title: '借用人',}
                , {field: 'borrowerdeptName', title: '借用部门',}
                , {
                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                        if (d.borrowTime == undefined || d.borrowTime == "") {
                            return d.borrowTime = ""
                        } else {
                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                            return d.borrowTime;
                        }
                    }
                }
                , {
                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                            return d.expectReturnDate = ""
                        } else {
                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                            return d.expectReturnDate;
                        }
                    }
                }
                , {field: 'borrowerOperationUser', title: '借出人'}
                , {field: 'lenddeptName', title: '借出部门'}
                , {
                    field: 'borrowOperationTime', title: '借出日期', templet: function (d) {
                        if (d.borrowOperationTime == undefined || d.borrowOperationTime == "") {
                            return d.borrowOperationTime = ""
                        } else {
                            d.borrowOperationTime = new Date(d.borrowOperationTime).Format("yyyy-MM-dd");
                            return d.borrowOperationTime;
                        }
                    }
                }
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'memo', title: '备注'}
                , {width: 200, title: '操作', align: 'center', toolbar: '#barOperation'}
            ]],
            done: function (res) {
                if (res.data.length > 0) {
                    var lendId = res.data[0].lendId;
                    equipTable("#deviceDetail", lendId, "#toolbars", col);
                } else {
                    cequipTable("#deviceDetail", "#", col);
                }
            }
        });

        //监听第一实例表格行单击事件
        table.on('row(SettlementFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据
            lendId = data.lendId
            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#deviceDetail", data.lendId, "#", col)
        });
        // 待批申请头部事件
        table.on('toolbar(SettlementFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'approval':
                    var data = table.checkStatus('Settlement').data;
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        var lendId = "";
                        var ApprovalStatus ="";
                        for (var i = 0; i < data.length; i++) {
                            lendId += data[i].lendId + ",";
                            ApprovalStatus+="2,"
                        }
                        $.ajax({
                            type: "post",
                            url: "/EquipBorrow/lendApprovalStatus",
                            dataType: "json",
                            data: {
                                lendId: lendId,
                                ApprovalStatus:ApprovalStatus
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg(res.msg);
                                    settlementTable.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                    break;
                case 'disApproval':
                    var data = table.checkStatus('Settlement').data;
                    var lendId = "";
                    var ApprovalStatus ="";
                    for (var i = 0; i < data.length; i++) {
                        lendId += data[i].lendId + ",";
                        ApprovalStatus+="3,"
                    }
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        $.ajax({
                            type: "post",
                            url: "/EquipBorrow/lendApprovalStatus",
                            dataType: "json",
                            data: {
                                lendId: lendId,
                                ApprovalStatus:ApprovalStatus
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg(res.msg);
                                    settlementTable.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                    break;
                case 'searchCust':
                    var inptext=$(".demoTable input[name='searchtext']").val();
                    var seletext=$(".demoTable").find("dl dd.layui-this").attr("lay-value");
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
        // 转移申请行内操作事件
        table.on('tool(SettlementFilter)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if (layEvent === 'approval') {
                var lendId = data.lendId + ",";
                var ApprovalStatus = "2,";
                $.ajax({
                    type: "post",
                    url: "/EquipBorrow/lendApprovalStatus",
                    dataType: "json",
                    data: {
                        lendId: lendId,
                        ApprovalStatus: ApprovalStatus
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg);
                            settlementTable.reload();
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                })
            } else if (layEvent === 'disApproval') {;
                var lendId = data.lendId + ",";
                var ApprovalStatus = "3,";
                $.ajax({
                    type: "post",
                    url: "/EquipBorrow/lendApprovalStatus",
                    dataType: "json",
                    data: {
                        lendId: lendId,
                        ApprovalStatus:ApprovalStatus
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg);
                            settlementTable.reload();
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                })
            }
        });

        //已准申请表格实例
        approvalTable = table.render({
            elem: '#approvalTable'
            , url: ''
            , data: []
            , page: true //开启分页
            , toolbar: '#accurate'
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: [[{type: 'checkbox', field: 'lendId'}
                , {
                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                        if (d.approverStatus == 0) {
                            return "新建"
                        } else if (d.approverStatus == 1) {
                            return "待批准"
                        } else if (d.approverStatus == 2) {
                            return "已批准"
                        } else if (d.approverStatus == 3) {
                            return "未批准"
                        }
                    }
                }
                , {field: 'borrowerUser', title: '借用人',}
                , {field: 'borrowerdeptName', title: '借用部门',}
                , {
                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                        if (d.borrowTime == undefined || d.borrowTime == "") {
                            return d.borrowTime = ""
                        } else {
                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                            return d.borrowTime;
                        }
                    }
                }
                , {
                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                            return d.expectReturnDate = ""
                        } else {
                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                            return d.expectReturnDate;
                        }
                    }
                }
                , {field: 'borrowerOperationUser', title: '借出人'}
                , {field: 'lenddeptName', title: '借出部门'}
                , {
                    field: 'borrowOperationTime', title: '借出时间', templet: function (d) {
                        if (d.borrowOperationTime == undefined || d.borrowOperationTime == "") {
                            return d.borrowOperationTime = ""
                        } else {
                            d.borrowOperationTime = new Date(d.borrowOperationTime).Format("yyyy-MM-dd");
                            return d.borrowOperationTime;
                        }
                    }
                }
                , {field: 'approver', title: '审批人'}

                , {
                    field: 'approverTime', title: '审批时间', templet: function (d) {
                        if (d.approverTime == undefined || d.approverTime == "") {
                            return d.approverTime = ""
                        } else {
                            d.approverTime = new Date(d.approverTime).Format("yyyy-MM-dd");
                            return d.approverTime;
                        }
                    }
                }
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'memo', title: '备注'}
            ]],
            done: function (res) {
                if(res.data.length >0){
                    var lendId = res.data[0].lendId;
                    equipTable("#approvalDetail",lendId,"#",col);
                }else{
                    cequipTable("#approvalDetail","#",col);
                }
            }
        });

        //监听第三实例表格行单击事件
        table.on('row(approvalTableFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据

            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#approvalDetail", data.lendId, "#", col)

        });

        //未准表格实例
        notexactlyTable = table.render({
            elem: '#notexactlyTable'
            , url: ''
            , data: []
            , toolbar: '#notexactly'
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: [[{type: 'checkbox', field: 'lendId'}
                , {
                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                        if (d.approverStatus == 0) {
                            return "新建"
                        } else if (d.approverStatus == 1) {
                            return "待批准"
                        } else if (d.approverStatus == 2) {
                            return "已批准"
                        } else if (d.approverStatus == 3) {
                            return "未批准"
                        }
                    }
                }
                , {field: 'borrowerUser', title: '借用人',}
                , {field: 'borrowerdeptName', title: '借用部门',}
                , {
                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                        if (d.borrowTime == undefined || d.borrowTime == "") {
                            return d.borrowTime = ""
                        } else {
                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                            return d.borrowTime;
                        }
                    }
                }
                , {
                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                            return d.expectReturnDate = ""
                        } else {
                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                            return d.expectReturnDate;
                        }
                    }
                }
                , {field: 'borrowerOperationUser', title: '借出人'}
                , {field: 'lenddeptName', title: '借出部门'}
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'memo', title: '备注'}
            ]],
            done: function (res) {
                if(res.data.length >0){
                    var lendId = res.data[0].lendId;
                    equipTable("#notexactlyDetail",lendId,"#toolbars",col);
                }else{
                    cequipTable("#notexactlyDetail","#toolbars",col);
                }
            }
        });

        //监听第三实例表格行单击事件
        table.on('row(notexactlyTableFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据

            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#notexactlyDetail", data.lendId, "#", col)

        });
        //设备借还表格实例
        devicebl = table.render({
            elem: '#devicebl'
            , url: ''
            , toolbar: '#accept'
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: [[{type: 'checkbox', field: 'lendId'}
                , {
                    field: 'returnStatus', title: '处理状态', templet: function (d) {
                        if (d.returnStatus == 0) {
                            return "全归还"
                        } else if (d.returnStatus == 1) {
                            return "部分归还"
                        } else if (d.returnStatus == 2) {
                            return "未归还"
                        }
                    }
                }
                , {field: 'borrowerUser', title: '借用人',}
                , {field: 'borrowerdeptName', title: '借用部门',}
                , {
                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                        if (d.borrowTime == undefined || d.borrowTime == "") {
                            return d.borrowTime = ""
                        } else {
                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                            return d.borrowTime;
                        }
                    }
                }
                , {
                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                            return d.expectReturnDate = ""
                        } else {
                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                            return d.expectReturnDate;
                        }
                    }
                }
                , {field: 'borrowerOperationUser', title: '借出人'}
                , {field: 'lenddeptName', title: '借出部门'}
                , {
                    field: 'borrowOperationTime', title: '借出时间', templet: function (d) {
                        if (d.borrowOperationTime == undefined || d.borrowOperationTime == "") {
                            return d.borrowOperationTime = ""
                        } else {
                            d.borrowOperationTime = new Date(d.borrowOperationTime).Format("yyyy-MM-dd");
                            return d.borrowOperationTime;
                        }
                    }
                }
                , {field: 'approver', title: '审批人'}
                , {
                    field: 'approverTime', title: '审批时间', templet: function (d) {
                        if (d.approverTime == undefined || d.approverTime == "") {
                            return d.approverTime = ""
                        } else {
                            d.approverTime = new Date(d.approverTime).Format("yyyy-MM-dd");
                            return d.approverTime;
                        }
                    }
                }
                , {field: 'workflowNo', title: '流水号'}
                , {field: 'memo', title: '备注'}
                // , {width: 100, title: '操作', align: 'center', toolbar: '#barOperation3'}
            ]]
            ,done:function (res) {
                if(res.data.length >0){
                    var lendId = res.data[0].lendId;
                    equipTable("#deviceblDetail",lendId,"#",mcol)
                }else{
                    cequipTable("#deviceblDetail","#",mcol)
                }
            }
        });
        //监听第四实例表格行单击事件
        table.on('row(deviceblFilter)', function (obj) {
            var tr = obj.tr //得到当前行元素对象
            var data = obj.data //得到当前行数据

            //选中行变颜色方法
            var index = $(this).attr('data-index');
            var tr = $(this).parent().children(tr);
            $(this).addClass("bg");
            for (var i = 0; i < tr.length; i++) {
                if (index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            equipTable("#deviceblDetail", data.lendId, "#", mcol)

        });
        //顶部页签切换事件
        element.on('tab(tabtoggle)', function (data) {
            var index = data.index;
            topindexPage=data.index;
            switch (index) {
                case 0:
                    settlementTable.reload({
                        url:'/EquipBorrow/getAdministration?ApprovalStatus=1'
                    })
                    break;
                case 1:
                    approvalTable.reload({
                        url:'/EquipBorrow/getAdministration?ApprovalStatus=2'
                    })
                    break;
                case 2:
                    notexactlyTable.reload({
                        url:'/EquipBorrow/getAdministration?ApprovalStatus=3'
                    })
                    break;
                case 3:
                    devicebl.reload({
                        url:'/EquipBorrow/getAdministration?ApprovalStatus=2'
                    })
                    break;
            }
        });

        /** 创建作者:   王穗穗
         * 创建日期:   12:15 2019/10/19
         * 方法介绍:
         * 参数说明:  设备借还单归还
         * @return
         */
        table.on('tool(deviceblFilter)', function (obj) {
            var events = obj.event;
            var data=obj.data;
            if (events == 'returnlend') {
                if(data.returnStatus==0){
                    layer.msg("设备已全部归还");
                    return false;
                }
                resutltopen("/EquipBorrow/Returnborrowing",data,"devicebl")
            }
        });

        /** 创建作者:   王穗穗
         * 创建日期:   10:35 2019/10/19
         * 方法介绍:
         * 参数说明:  设备归还
         * @return
         */
        table.on('tool(borrowDlFilter)', function (obj) {
            var events = obj.event;
            var data=obj.data;
            if (events == 'returnlend') {
                if(data.returnStatus==1){
                    layer.msg("设备已归还");
                    return false;
                }
                resutltopen("/EquipBorrow/Returnquipborrowing",data,"devicebl")
            }

        });
        //待批
        // 已批头部事件
        table.on('toolbar(approvalTableFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'searchCusta':
                    var inptext=$(".demoTablea input[name='searchtexta']").val();
                    var seletext=$(".demoTablea").find("dl dd.layui-this").attr("lay-value");
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
        // 未准表头部事件
        table.on('toolbar(notexactlyTableFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'searchCustb':
                    var inptext=$(".demoTableb input[name='searchtextb']").val();
                    var seletext=$(".demoTableb").find("dl dd.layui-this").attr("lay-value");
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
        // 设备接收头部事件
        table.on('toolbar(deviceblFilter)', function (obj) {
            var layEvent = obj.event;
            switch (layEvent) {
                case 'searchCustc':
                    var inptext=$(".demoTablec input[name='searchtextc']").val();
                    var seletext=$(".demoTablec").find("dl dd.layui-this").attr("lay-value");
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            inptext:inptext,
                            column:seletext
                        }
                        searchCusInfo(datas)
                    }
                    break;
            }
        });
    })
/******************************************************************自定义方法区****************************************************************************************************/
        //模糊查询
        function searchCusInfo(data) {
            var parm={}
            if(data.column=="RETURN_STATUS"){
                if(data.inptext=="部分归还"){
                    data.inptext=1;
                }if(data.inptext=="全部归还"){
                    data.inptext=2
                }if(data.inptext=="未归还"){
                    data.inptext=0;
                }
            }
            var url="/EquipBorrow/getAdministration"
            if (topindexPage == 0) {
                parm = {
                    ApprovalStatus: 1,
                    column: data.column,
                    inptext: data.inptext
                }
                $.ajax({
                    type: 'post'
                    ,url:url
                    , data: parm
                    , dataType: 'json',
                    success: function (res) {
                        var datas = res.data;
                        layui.table.render({
                            elem: '#Settlement'
                            , data: datas
                            , page: true //开启分页
                            , url: ''//数据接口
                            , toolbar: '#toolbar'
                            ,cols: [[{type: 'checkbox', field: 'lendId'}
                                , {
                                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                                        if (d.approverStatus == 0) {
                                            return "新建"
                                        } else if (d.approverStatus == 1) {
                                            return "待批准"
                                        } else if (d.approverStatus == 2) {
                                            return "已批准"
                                        } else if (d.approverStatus == 3) {
                                            return "未批准"
                                        }
                                    }
                                }
                                , {field: 'borrowerUser', title: '借用人',}
                                , {field: 'borrowerdeptName', title: '借用部门',}
                                , {
                                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                                        if (d.borrowTime == undefined || d.borrowTime == "") {
                                            return d.borrowTime = ""
                                        } else {
                                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                                            return d.borrowTime;
                                        }
                                    }
                                }
                                , {
                                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                                            return d.expectReturnDate = ""
                                        } else {
                                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                                            return d.expectReturnDate;
                                        }
                                    }
                                }
                                , {field: 'borrowerOperationUser', title: '借出人'}
                                , {field: 'lenddeptName', title: '借出部门'}
                                , {
                                    field: 'borrowOperationTime', title: '借出日期', templet: function (d) {
                                        if (d.borrowOperationTime == undefined || d.borrowOperationTime == "") {
                                            return d.borrowOperationTime = ""
                                        } else {
                                            d.borrowOperationTime = new Date(d.borrowOperationTime).Format("yyyy-MM-dd");
                                            return d.borrowOperationTime;
                                        }
                                    }
                                }
                                , {field: 'workflowNo', title: '流水号'}
                                , {field: 'memo', title: '备注'}
                                , {width: 200, title: '操作', align: 'center', toolbar: '#barOperation'}
                            ]],
                            done: function (res) {
                                if (res.data.length > 0) {
                                    var lendId = res.data[0].lendId;
                                    equipTable("#deviceDetail", lendId, "#toolbars", col);
                                } else {
                                    cequipTable("#deviceDetail", "#", col);
                                }
                                $(".demoTable input[name='searchtext']").val(data.inptext);
                                $(".demoTable").find("select[name='modules']").each(function () {
                                    // this代表的是<option></option>，对option再进行遍历
                                    $(this).children("option").each(function () {
                                        // 判断需要对那个选项进行回显
                                        if (this.value == data.column) {
                                            // 进行回显
                                            $(this).attr("selected", "selected");
                                        }
                                    });
                                })
                                layui.form.render('select');
                            }
                        })
                    }

                })
            } else if (topindexPage == 1) {
                parm = {
                    ApprovalStatus: 2,
                    column: data.column,
                    inptext: data.inptext
                }
                $.ajax({
                    type: 'post'
                    ,url:url
                    , data: parm
                    , dataType: 'json',
                    success: function (res) {
                        var datas = res.data;

                        layui.table.render({
                            elem: '#approvalTable'
                            , url: ''
                            , data: datas
                            , page: true //开启分页
                            , toolbar: '#accurate'
                            , limit: 5 //每页默认显示的数量
                            , limits: [5, 10, 15, 20, 25, 30]
                            , cols: [[{type: 'checkbox', field: 'lendId'}
                                , {
                                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                                        if (d.approverStatus == 0) {
                                            return "新建"
                                        } else if (d.approverStatus == 1) {
                                            return "待批准"
                                        } else if (d.approverStatus == 2) {
                                            return "已批准"
                                        } else if (d.approverStatus == 3) {
                                            return "未批准"
                                        }
                                    }
                                }
                                , {field: 'borrowerUser', title: '借用人',}
                                , {field: 'borrowerdeptName', title: '借用部门',}
                                , {
                                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                                        if (d.borrowTime == undefined || d.borrowTime == "") {
                                            return d.borrowTime = ""
                                        } else {
                                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                                            return d.borrowTime;
                                        }
                                    }
                                }
                                , {
                                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                                            return d.expectReturnDate = ""
                                        } else {
                                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                                            return d.expectReturnDate;
                                        }
                                    }
                                }
                                , {field: 'borrowerOperationUser', title: '借出人'}
                                , {field: 'lenddeptName', title: '借出部门'}
                                , {
                                    field: 'borrowOperationTime', title: '借出时间', templet: function (d) {
                                        if (d.borrowOperationTime == undefined || d.borrowOperationTime == "") {
                                            return d.borrowOperationTime = ""
                                        } else {
                                            d.borrowOperationTime = new Date(d.borrowOperationTime).Format("yyyy-MM-dd");
                                            return d.borrowOperationTime;
                                        }
                                    }
                                }
                                , {field: 'approver', title: '审批人'}

                                , {
                                    field: 'approverTime', title: '审批时间', templet: function (d) {
                                        if (d.approverTime == undefined || d.approverTime == "") {
                                            return d.approverTime = ""
                                        } else {
                                            d.approverTime = new Date(d.approverTime).Format("yyyy-MM-dd");
                                            return d.approverTime;
                                        }
                                    }
                                }
                                , {field: 'workflowNo', title: '流水号'}
                                , {field: 'memo', title: '备注'}
                            ]],
                            done: function (res) {
                                if(res.data.length >0){
                                    var lendId = res.data[0].lendId;
                                    equipTable("#approvalDetail",lendId,"#",col);
                                }else{
                                    cequipTable("#approvalDetail","#",col);
                                }
                                $(".demoTablea input[name='searchtexta']").val(data.inptext);
                                $(".demoTablea").find("select[name='modules']").each(function () {
                                    // this代表的是<option></option>，对option再进行遍历
                                    $(this).children("option").each(function () {
                                        // 判断需要对那个选项进行回显
                                        if (this.value == data.column) {
                                            // 进行回显
                                            $(this).attr("selected", "selected");
                                        }
                                    });
                                })
                                layui.form.render('select');
                            }
                        });
                    }
                })
            } else if (topindexPage == 2) {
                parm = {
                    ApprovalStatus: 3,
                    column: data.column,
                    inptext: data.inptext
                }
                $.ajax({
                    type: 'post'
                    ,url:url
                    , data: parm
                    , dataType: 'json',
                    success: function (res) {
                        var datas = res.data;
                        layui.table.render({
                            elem: '#notexactlyTable'
                            , url: ''
                            , data: datas
                            , toolbar: '#notexactly'
                            , page: true //开启分页
                            , limit: 5 //每页默认显示的数量
                            , limits: [5, 10, 15, 20, 25, 30]
                            , cols: [[{type: 'checkbox', field: 'lendId'}
                                , {
                                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                                        if (d.approverStatus == 0) {
                                            return "新建"
                                        } else if (d.approverStatus == 1) {
                                            return "待批准"
                                        } else if (d.approverStatus == 2) {
                                            return "已批准"
                                        } else if (d.approverStatus == 3) {
                                            return "未批准"
                                        }
                                    }
                                }
                                , {field: 'borrowerUser', title: '借用人',}
                                , {field: 'borrowerdeptName', title: '借用部门',}
                                , {
                                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                                        if (d.borrowTime == undefined || d.borrowTime == "") {
                                            return d.borrowTime = ""
                                        } else {
                                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                                            return d.borrowTime;
                                        }
                                    }
                                }
                                , {
                                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                                            return d.expectReturnDate = ""
                                        } else {
                                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                                            return d.expectReturnDate;
                                        }
                                    }
                                }
                                , {field: 'borrowerOperationUser', title: '借出人'}
                                , {field: 'lenddeptName', title: '借出部门'}
                                , {field: 'workflowNo', title: '流水号'}
                                , {field: 'memo', title: '备注'}
                            ]]
                            ,done:function (res) {
                                if(res.data.length >0){
                                    var lendId = res.data[0].lendId;
                                    equipTable("#notexactlyDetail",lendId,"#",mcol)
                                }else{
                                    cequipTable("#notexactlyDetail","#",mcol)
                                }
                                // $("#" + searchColum + "").val($("#" + searchColum + "").val())
                                // $("#colum").find('option[value="' + searchColum + '"]').prop('selected', 'selected');
                                $(".demoTableb input[name='searchtextb']").val(data.inptext);
                                $(".demoTableb").find("select[name='modules']").each(function () {
                                    // this代表的是<option></option>，对option再进行遍历
                                    $(this).children("option").each(function () {
                                        // 判断需要对那个选项进行回显
                                        if (this.value == data.column) {
                                            // 进行回显
                                            $(this).attr("selected", "selected");
                                        }
                                    });
                                })
                                layui.form.render('select');
                            }
                        });
                    }
                })
            } else if (topindexPage == 3) {
                if(data.column=="RECEIVE_STATUS"){
                    if(data.inptext=="全部接收"){
                        data.inptext=2
                    }
                    if(data.inptext=="部分接收"){
                        data.inptext=1
                    }
                    if(data.inptext=="未接收"){
                        data.inptext=0
                    }

                }
                parm = {
                    ApprovalStatus:2,
                    column: data.column,
                    inptext: data.inptext
                }
                $.ajax({
                    type: 'post'
                    ,url:url
                    , data: parm
                    , dataType: 'json',
                    success: function (res) {
                        var datas = res.data;
                        layui.table.render({
                            elem: '#devicebl'
                            , url: ''
                            , data: datas
                            , toolbar: '#accept'
                            , page: true //开启分页
                            , limit: 5 //每页默认显示的数量
                            , limits: [5, 10, 15, 20, 25, 30]
                            , cols: [[{type: 'checkbox', field: 'lendId'}
                                , {
                                    field: 'returnStatus', title: '处理状态', templet: function (d) {
                                        if (d.returnStatus == 0) {
                                            return "全归还"
                                        } else if (d.returnStatus == 1) {
                                            return "部分归还"
                                        } else if (d.returnStatus == 2) {
                                            return "未归还"
                                        }
                                    }
                                }
                                , {field: 'borrowerUser', title: '借用人',}
                                , {field: 'borrowerdeptName', title: '借用部门',}
                                , {
                                    field: 'borrowTime', title: '借用日期', templet: function (d) {
                                        if (d.borrowTime == undefined || d.borrowTime == "") {
                                            return d.borrowTime = ""
                                        } else {
                                            d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                                            return d.borrowTime;
                                        }
                                    }
                                }
                                , {
                                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                                        if (d.expectReturnDate == undefined || d.expectReturnDate == "") {
                                            return d.expectReturnDate = ""
                                        } else {
                                            d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                                            return d.expectReturnDate;
                                        }
                                    }
                                }
                                , {field: 'borrowerOperationUser', title: '借出人'}
                                , {field: 'lenddeptName', title: '借出部门'}
                                , {
                                    field: 'borrowOperationTime', title: '借出时间', templet: function (d) {
                                        if (d.borrowOperationTime == undefined || d.borrowOperationTime == "") {
                                            return d.borrowOperationTime = ""
                                        } else {
                                            d.borrowOperationTime = new Date(d.borrowOperationTime).Format("yyyy-MM-dd");
                                            return d.borrowOperationTime;
                                        }
                                    }
                                }
                                , {field: 'approver', title: '审批人'}
                                , {
                                    field: 'approverTime', title: '审批时间', templet: function (d) {
                                        if (d.approverTime == undefined || d.approverTime == "") {
                                            return d.approverTime = ""
                                        } else {
                                            d.approverTime = new Date(d.approverTime).Format("yyyy-MM-dd");
                                            return d.approverTime;
                                        }
                                    }
                                }
                                , {field: 'workflowNo', title: '流水号'}
                                , {field: 'memo', title: '备注'}
                                , {width: 100, title: '操作', align: 'center', toolbar: '#barOperation3'}
                            ]]
                            ,done:function (res) {
                                if(res.data.length >0){
                                    var lendId = res.data[0].lendId;
                                    equipTable("#deviceblDetail",lendId,"#",mcol)
                                }else{
                                    cequipTable("#deviceblDetail","#",mcol)
                                }
                                // $("#" + searchColum + "").val($("#" + searchColum + "").val())
                                // $("#colum").find('option[value="' + searchColum + '"]').prop('selected', 'selected');
                                $(".demoTablec input[name='searchtextc']").val(data.inptext);
                                $(".demoTablec").find("select[name='modules']").each(function () {
                                    // this代表的是<option></option>，对option再进行遍历
                                    $(this).children("option").each(function () {
                                        // 判断需要对那个选项进行回显
                                        if (this.value == data.column) {
                                            // 进行回显
                                            $(this).attr("selected", "selected");
                                        }
                                    });
                                })
                                layui.form.render('select');
                            }
                        });
                    }
                })
            }

        }

    //设备转移明细表格实例
    function equipTable(gid,logid,tid,col) {
        layui.table.render({
            elem: gid
            ,data:[]
            , url: '/EquipBorrow/getLendList?lendId='+logid
            ,toolbar:tid
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: col
        });
    }
    function cequipTable(gid,tid,col) {
        layui.table.render({
            elem: gid
            ,data:[]
            ,toolbar:tid
            , page: true //开启分页
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            , cols: col
        });
    }
    /**  归还具体操作 **/
    function resutltopen(url,data,table){
        var index = layer.open({
            type: 1,
            area: ['500px', '300px'], //宽高
            title: '归还信息',
            maxmin: true,
            btn: ['提交', '取消'],
            content: '<form class="layui-form"  lay-filter="formTest" >' +
            '<div class="one" id="PositionName"><div class="layui-form-item" style="margin: 20px 0;"><label class="layui-form-label" style="width: 150px;"><span style="color: red">*</span>归还人：</label><div class="layui-input-inline" id="tre" style="width: 200px;">' +
            '<div class="layui-input" onclick="xuanren()" style="height: 30px;line-height:30px;"id="returnUser"></div>'+
            '<input type="text" hidden name="name="returnUser">'+
            '<input type="text" disabled name="borrowerUser"  placeholder="请输入" autocomplete="off" class="layui-input" style="display: none;"></div></div></div>'+
            '<div class="one"><div class="layui-form-item"><label class="layui-form-label" style="width: 150px;">归还时间：</label><div class="layui-input-inline" style="width: 200px;">' +
            '<input placeholder="请输入" disabled id="returnTime" style="color:#888;height: 32px;" type="text" name="returnTime" autocomplete="off" class="layui-input"></div></div></div>' +
            '</form>',
            success: function () {
                $("#returnTime").val(nowformat);
                layui.form.render();
            },
            yes: function (index, layero) {
                if($("#returnUser").next().val()==""){
                    layui.layer.msg("请选择归还人");
                    return false;
                }
                var param={};
                if(data.lendListId==undefined){
                    param={
                        returnUser:$("#returnUser").next().val(),
                        lendId:data.lendId
                    }
                }else {
                    param = {
                        lendListId: data.lendListId,
                        equipId: data.equipId,
                        returnUser: $("#returnUser").next().val(),
                        lendId: data.lendId
                    }
                }
                layui.layer.close(index);
                toAjax(url,param,table,data.lendId);
            }
        });
    }
    function toAjax(url, data, table,lendId) {
        var result;
        $.ajax({
            url: url,
            data: data,
            type: 'post',
            async: false,
            dataType: 'json',
            success: function (res) {
                result = res;
                layer.msg(res.msg);
                devicebl.reload();
                equipTable("#deviceblDetail",lendId,"#",scol)
            }
        });
        return result;
    }

    //获取当前时间  年月日
    function nowformat() {
        var nstr = "";
        var now = new Date();
        var nyear = now.getFullYear();
        var nmonth = now.getMonth() + 1;
        var nday = now.getDate();
        if (nmonth < 10) {
            nmonth = "0" + nmonth;
        }
        if (nday < 10) {
            nday = "0" + nday;
        }
        nstr = nyear + "-" + nmonth + "-" + nday;
        return nstr;
    }
    //选人员

    function xuanren(me) {
        $.popWindow("../common/lmisSelectUserExp?0");
    }

    /** 创建作者:   王穗穗
     * 创建日期:   11:26 2019/10/19
     * 方法介绍:
     * 参数说明:   设备归还回显数据
     * @return
     */
    function returnlendlist(res){
        $("#returnUser").text(res.userName);
        $("#returnUser").next().val(res.userIds);
    }
</script>
</body>
</html>

